import request from '@/utils/request'

// 查询角色列表
export function list(query) {
  return request({
    url: '/system/user/page',
    method: 'get',
    params: query
  })
}

// 查询角色详细
export function get(roleId) {
  return request({
    url: '/system/user/' + roleId,
    method: 'get'
  })
}

// 查询角色详细
export function listExcelHeader() {
  return request({
    url: '/system/user/excel/header',
    method: 'get'
  })
}

// 新增角色
export function add(data) {
  return request({
    url: '/system/user',
    method: 'post',
    data: data
  })
}

// 修改角色
export function update(data) {
  return request({
    url: '/system/user',
    method: 'patch',
    data: data
  })
}

// 导出角色
export function exportData(data, pageParam) {
  return request({
    responseType: 'blob',
    url: '/system/user/download/excel' + pageParam,
    method: 'post',
    data: data
  })
}

export function uploadData(data) {
  return request({
    url: '/system/user/upload/excel',
    method: 'post',
    data: data
  })
}

// 删除角色
export function deleteData(ids) {
  return request({
    url: '/system/user',
    method: 'delete',
    data: ids
  })
}

// 登录成功获取用户系统信息
export function getInfo() {
  return request({
    url: '/system/user/info',
    method: 'get'
  })
}

export function grantRole(data) {
  return request({
    url: '/system/user/grant',
    method: 'post',
    data: data
  })
}
